#include <algorithm>
#include <cstdint>
#include <iostream>
#include <istream>

using ll = int;

// const ll max_n = (ll)1e6+5;
// ll a[max_n], f[max_n];

int main(){
    std::iostream::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
    ll n;
    std::cin>>n;
    const ll max_n = (ll)5e3+5;
    ll *a = new ll[max_n], *f = new ll[max_n];
    for(ll i{1};i<=n;i++){
        std::cin>>a[i];
    }
    std::fill(f, f+max_n, 1);
    ll max{};
    for(ll i{2};i<=n;i++){
        for(ll j{1};j<i;j++){
            if(a[i]>a[j]){
                f[i] = std::max(f[i], f[j]+1);
            }
        }
        max = std::max(max, f[i]);
    }
    std::cout<<max<<'\n';
}